import 'package:nsd/nsd.dart';

class RecvFile {
  String name = "";
  bool isRecvied = false;
  double progress = 0.0;

  RecvFile(this.name);

  @override
  String toString() {
    return "name: $name, isRecvied: $isRecvied, progress: $progress";
  }
}

const List<String> videoFormats = ['.mp4', '.mov', '.avi', '.wmv', '.3gp', '.3gpp', '.mkv', '.flv'];
const List<String> imageFormats = ['.jpeg', '.png', '.jpg', '.gif', '.webp', '.tif', '.heic'];

bool isVideo(String path) {
  bool output = false;
  for (var videoFormat in videoFormats) {
    if (path.toLowerCase().contains(videoFormat)) output = true;
  }
  return output;
}

bool isImage(String path) {
  bool output = false;
  for (var imageFormat in imageFormats) {
    if (path.toLowerCase().contains(imageFormat)) output = true;
  }
  return output;
}

extension NLService on Service {
  String? xhost() {
    if (addresses != null) {
      return addresses?.first.address;
    }
    return host;
  }

  String xname() {
    return (name ?? "unknown").replaceAll("FileLinker", "").trim();
  }
}
